package org.tech4j.common.core.request.param;

import com.google.common.collect.Maps;
import jakarta.servlet.http.HttpServletRequest;
import org.tech4j.common.spi.ExtensionLoader;

import java.util.Map;

/**
 * @program: tech4j-common
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/2 20:00
 **/
public final class ParameterDataFactory {

    /**
     * New instance parameter data.
     * @param paramType paramType
     * @return
     */
    public static ParameterData newInstance(final String paramType) {
        return ExtensionLoader.getExtensionLoader(ParameterData.class).getJoin(paramType);
    }

    /**
     * Builder data string.
     * @param paramType paramType
     * @param paramName paramName
     * @param request request
     * @return
     */
    public static String buildData(final String paramType, final String paramName, final HttpServletRequest request) {
        return newInstance(paramType).builder(paramName, request);
    }

    /**
     * Builder data string.
     * @param paramType paramType
     * @param paramName paramName
     * @param request request
     * @return
     */
    public static Map<String, Object> buildMapData(final String paramType, final String paramName, final HttpServletRequest request) {
        return newInstance(paramType).builderMap(paramName, request);
    }
}
